<template>
  <div>
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
      <el-form-item label="用户名称：">
        <el-input v-model="ruleForm.username" auto-complete="off"></el-input>
      </el-form-item>
      <el-form-item label="密码：">
        <el-input   v-model="ruleForm.password" show-password auto-complete="off"></el-input>
      </el-form-item>
      
      <el-form-item>
        <el-button type="primary" @click="submitForm('ruleForm')"
          >登录</el-button
        >
        <el-button @click="resetForm('ruleForm')">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        ruleForm: {
          username: '',
          password: '',
        },
        rules: {
          rule: {
            LoginName: [
              { required: true, message: '请输入用户名称', trigger: 'blur' }
            ],
            LoginPwd: [
              { required: true, message: '请输入密码', trigger: 'blur' }
            ],
          },         
        },
      };
    },
    methods: {
      submitForm(ruleForm) {
        this.axios
        .get("https://localhost:44331/api/app/login/login?username="+this.ruleForm.username+"&password="+this.ruleForm.password)
        .then((res)=>{
          console.log(res);
          if(res.status==200){
            alert("登陆成功");
            this.$router.push("/Show/Cargo_Information");
          }else{
            alert("登录失败");
          }
        })
      }
    }
  }
</script>

